package com.ruoyi.project.pigtest;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentStyle;
import com.alibaba.excel.enums.poi.FillPatternTypeEnum;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.pig4cloud.plugin.excel.annotation.ExcelLine;
import com.pig4cloud.plugin.excel.annotation.ResponseExcel;
import com.pig4cloud.plugin.excel.annotation.Sheet;
import com.ruoyi.framework.aspectj.lang.annotation.Anonymous;
import lombok.Data;
import org.apache.poi.ss.usermodel.FillPatternType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@Anonymous
public class PigExcelController {

    @ResponseExcel(name = "#param + '导出'")
    @GetMapping("/e1")
    public List<DemoData> e1(String param) {
        List<DemoData> dataList = new ArrayList<>();
        for (int i = 0; i < 100; i++) {
            DemoData data = new DemoData();
            data.setUsername("tr1" + i);
            data.setPassword("tr2" + i);
            data.setType("1");
            dataList.add(data);
        }
        return dataList;
    }


}

@Data
class DemoData {
    @ColumnWidth(50)  // 定义宽度
    @ExcelProperty("用户名") // 定义列名称
    private String username;
    @ExcelProperty("密码")
    //@ExcelIgnore // 忽略这个字段
    private String password;

    @ExcelLine
    //@DictTypeProperty
    private String type;

    private String typeName2;
}

